package com.ruoyi.system.common;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.ruoyi.system.domain.from.CrmCustomerUserInfoOther;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;


@Slf4j
public class OtherReadExcelListener extends AnalysisEventListener<CrmCustomerUserInfoOther> {
    private int rowNumber = 0;

    public final static HashSet<String> HEAD = new HashSet<String>() {{
        add("姓名");
        add("证件号码");
        add("日期");
    }};

    List<CrmCustomerUserInfoOther> data = new ArrayList<>();

    public List<CrmCustomerUserInfoOther> getData() {
        return data;
    }

    public void setPinKunList(List<CrmCustomerUserInfoOther> data) {
        this.data = data;
    }

    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        super.invokeHeadMap(headMap, context);
    }

    @Override
    public void invoke(CrmCustomerUserInfoOther customerUserInfoOther, AnalysisContext analysisContext) {
        if (customerUserInfoOther!=null){
            if (customerUserInfoOther.getUserName().equals("姓名")
                    &&customerUserInfoOther.getUserIdentityCardNumber().equals("证件号码")
                    &&(customerUserInfoOther.getFeesDate().equals("日期") || customerUserInfoOther.getFeesDate().equals("对应费款所属期"))){
                log.info("导入数据剔除行中的标题");
            }else {
                data.add(customerUserInfoOther);
            }
        }
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
    }


}